﻿Ext.define('CosimRisk.view.SimulationGrid', {
    extend: 'Ext.grid.Panel',
    alias: 'widget.SimulationGrid',
    id: 'SimulationGrid',
    closable:true,
    title: '仿真版本信息',
    selModel: Ext.create( 'Ext.selection.CheckboxModel', {
        mode: "SINGlE",
        showHeaderCheckbox: false
    } ),
    store: 'SimulationStore',
    columns: [{
        xtype: 'rownumberer',
        width: 50,
        text: '序号'
    }, {
        text: '项目名称',
        dataIndex: 'projectName',
        flex: 1
    }, {
        text: '版本名称',
        dataIndex: 'desciption',
        flex: 1
    }, {
        text: '仿真次数',
        dataIndex: 'count',
        flex: 0.5
    }, {
        text: '开始时间',
        dataIndex: 'simStarttime',
        flex: 1
    },
    {
        text: '结束时间',
        dataIndex: 'simEndtime',
        flex: 1
    }],
    buttons: [{
        xtype: 'button',
        text: '选择该版本查看',
        id: 'chooseSimBtn'
    },{
        xtype: 'button',
        text: '开始一次新仿真',
        id: 'newSimBtn'
    }],
    dockedItems: [{
        xtype: 'pagingtoolbar',
       store: 'SimulationStore',
        dock: 'bottom',
        displayInfo: true
    },{
        xtype: 'toolbar',
        dock: 'top',
        items: [
            {
                xtype: 'combo',
                id:'Sim_combo',
                fieldLabel: '查看项目',
                value: '全部',
                editable:false,
                labelWidth: 60,
                store: 'SimulationcomboStore',
                valueField:'PRJ_NAME',
                displayField: 'PRJ_NAME',
                listeners: {
                    'change': function (o, newValue, oldValue, eOpts) {
                        var store = Ext.getCmp('SimulationGrid').getStore();
                        store.clearFilter();
                        var filter = function (record, id) {
                            if (record.get("projectName") == newValue)
                                return true;
                            else
                                return false;
                        };
                        if (newValue != '全部')
                        store.addFilter(filter);
                    }
                },
            }
        ]
    }]
});